//
//  PublishRentFirstCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2017/12/26.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import "PublishRentFirstCell.h"

@interface PublishRentFirstCell ()

@property (weak, nonatomic) IBOutlet UILabel *middleLabel;
@property (weak, nonatomic) IBOutlet UIImageView *leftImageView;
@property (weak, nonatomic) IBOutlet UITextField *rightTextField;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomMargin;

@end

@implementation PublishRentFirstCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    self.bottomMargin.constant = 0;
    
    self.middleLabel.font = MYFONT(16);
    
    self.rightTextField.font = MYFONT(14);
    
    //    self.rightLabel.textColor = [UIColor redColor];
    
    self.middleLabel.textColor = darkGray;
    
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.rightTextField];

}

- (void)setIndex:(NSIndexPath *)index{
    _index = index;
    
    self.leftImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"rentPulish00%ld",_index.row]];
    
    if (self.index.row == 0) {
        
        self.rightTextField.placeholder = @"位置(所在小区)";
        
        self.middleLabel.text = @"房源位置:";
        
        self.rightTextField.keyboardType = UIKeyboardTypeDefault;

        
    } else if (self.index.row == 10) {
        
        self.rightTextField.placeholder = @"填写手机号";
        
        self.middleLabel.text = @"联系电话:";
        
        self.rightTextField.keyboardType = UIKeyboardTypeNumberPad;


    }
    
    
}


- (void)setModel:(HouseParameterModel *)model{
    _model = model;
    
    
    if (self.index.row == 0) {
        
        if (_model.house_name.length > 0) {
            
            self.rightTextField.text = _model.house_name;
        }
    } else if (self.index.row == 10){
        
        if (_model.house_phone.length > 0) {
            
            self.rightTextField.text = _model.house_phone;
        }
        
    }else{
        
        
    }
    

}



- (void)textChange{
    
    if (self.index.row == 0) {
        
        self.model.house_name = self.rightTextField.text;

    } else if (self.index.row == 10){
        
        self.model.house_phone = self.rightTextField.text;

        
    }else{
        
        
    }
    
    
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
